package name.marz.to.go.ahg.mufgbk.executer;

import name.marz.to.go.ahg.core.checker.DocumentChecker;
import name.marz.to.go.ahg.core.exception.CannotLoginException;
import name.marz.to.go.ahg.core.exception.UserProcessException;

import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class MUFGbkLoginChecker implements DocumentChecker {
	private static final String ERR_RECOGNIZE_CLASS = "attention";

	@Override
	public void check(Document doc) throws UserProcessException {
		// ログインエラーチェック
		Elements elems = doc.getElementsByClass(ERR_RECOGNIZE_CLASS);
		if ( elems.size() > 0 ) {
			CannotLoginException cle = new CannotLoginException(
					elems.first().text()
					);
			cle.setDocument(doc);
			throw cle;
		}
		return;
	}
}